/**
 * 
 */
package views;

import java.util.Calendar;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import models.EventData;
import models.JProgressPanelDefaultModel;

/**
 * @author LAP
 *
 */
public class MainFrameContentCeeper extends JScrollPane{
	private JPanel contentCeeper;
	/**
	 * 
	 */
	private static final long serialVersionUID = -1818645586086562773L;
	
	public MainFrameContentCeeper() {
		contentCeeper = new JPanel();
		contentCeeper.setLayout(new BoxLayout(contentCeeper, BoxLayout.PAGE_AXIS));
		setViewportView(contentCeeper);
	}
	
	public void addEvent(EventData event) {
		if (event == null) throw new NullPointerException("Event must be not null");
		JProgressPanel panel = new JProgressPanel(event.getName());
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(event.getFullEndDate());
		JProgressPanelDefaultModel model = new JProgressPanelDefaultModel(calendar, panel);
		model.start();
		panel.setModel(model);
		contentCeeper.add(panel);
		contentCeeper.add(Box.createHorizontalGlue());
		updateUI();
	}
}
